package company;

import org.iweb.html.api.GroovyListener
import org.iweb.html.impl.basic.Button
import org.iweb.html.impl.basic.Div
import org.iweb.html.impl.basic.Form.CustomFormBean
import org.iweb.html.impl.js.engine.JavascriptEngine
import org.iweb.web.ui.page.Page;

@Page(path="/")
class Index{

	private Div toShow=new Div();
	
	def run(JavascriptEngine jsEngine,CustomFormBean bean){		
		jsEngine.show(toShow);
	}
	
	@Override
	public Object render() {
		
		Div masterRow=new Div();		
		masterRow.setClassStyle("row-fluid");
		
		Div container=new Div();
		container.setClassStyle("span12");
		
		masterRow.append(container);
		
		container.append(getTest())
		
		toShow.css("display", "none");
		toShow.append(new Div("On Show!"));
		
		container.append(toShow);
		
		return masterRow;
		
	}
	
	public Div getTest(){
		
		Div center=new Div();
		center.setClassStyle("span4 offset4");
		
		Button b =new Button("Click Me!");
		b.setClassStyle("btn btn-primary btn-large");	
		b.onClick(new GroovyListener("b-button-click",this,"run"));
		
		center.append(b)
		
		return center;
	}

}